package com.gxa.shop.servlet.brand;

import com.gxa.shop.bean.vo.BrandOption;
import com.alibaba.fastjson.JSON;
import com.gxa.shop.commons.r.R;
import com.gxa.shop.service.brand.BrandService;
import com.gxa.shop.service.brand.impl.BrandServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * com.gxa.shop.bean.servlet.brand
 * User: zjy
 * Date: 2024/12/18 10:45
 * motto:   逆水行舟不进则退
 * Description:
 * Version: V1.0
 */
@WebServlet(name = "BrandAllListServlet",value = "/brand/findAllList")
public class BrandAllListServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BrandService brandService=new BrandServiceImpl();
        List<BrandOption> list= brandService.findAllList();
        R r;
        r=list!=null?R.ok().addData("list",list):R.ok("没有品牌信息");
        PrintWriter writer = resp.getWriter();
        String  result= JSON.toJSONString(r);
        System.out.println("FindAllListServlet:"+result);
        writer.write(result);
        writer.flush();
        writer.close();
    }
}